let config = {
    cache_prefix: 'cache_'
}

function getDate() {
    let now = new Date();
    let year = now.getFullYear();
    let month = String(now.getMonth() + 1).padStart(2, '0');
    let day = String(now.getDate()).padStart(2, '0');
    let hours = String(now.getHours()).padStart(2, '0');
    let minutes = String(now.getMinutes()).padStart(2, '0');
    let seconds = String(now.getSeconds()).padStart(2, '0');
    return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
}


function clearLocalStorage() {
    let tmpObj = JSON.parse(JSON.stringify(localStorage))		// 深拷贝
    for (let key in tmpObj) {
        let reg = new RegExp("^" + config.cache_prefix, "g");
        if (reg.test(key) === true) {
            localStorage.removeItem(key)
            // console.log(key)
            // console.log('已删除')
        }
    }
}

function setLocalStorage(key, value) {
    localStorage.setItem(config.cache_prefix + '_' + key, value);
}

function getLocalStorage(key) {
    return localStorage.getItem(config.cache_prefix + '_' + key);
}

function getUrlParam(key) {
    const params = new URLSearchParams(window.location.search);
    return params.get(key);
}
